// pages/details/details.js

/* 
  详细信息: https://locally.uieee.com/categories/1/shops?item=1
 
 */
const fetch = require("../../utils/fetch.js")

Page({
  /**
   * 页面的初始数据
   */
  data: {
    shop: []
  },
  // 点击图片放大
  previewHandle(e) {
    wx.previewImage({
      current: e.currentTarget.dataset.src,
      urls: this.data.shop.images
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.item)
    fetch(`shops/${options.item}`).then(res => {
      console.log(res.data.name)
      this.setData({
        shop: res.data
      })
      wx.setNavigationBarTitle({
        title: res.data.name
      })
    })
  }
})